package io.github.wanggit.antrpc.commons.rate;

import io.github.wanggit.antrpc.commons.bean.RegisterBeanMethod;

public class LimitInfo {
    private final int limit;
    private final int durationInSeconds;

    LimitInfo(int limit, int durationInSeconds) {
        this.limit = limit;
        this.durationInSeconds = durationInSeconds;
    }

    public int getLimit() {
        return limit;
    }

    public int getDurationInSeconds() {
        return durationInSeconds;
    }

    public static boolean checkEquals(LimitInfo limitInfo, RegisterBeanMethod registerBeanMethod) {
        return null != limitInfo
                && null != registerBeanMethod
                && limitInfo.getLimit() == registerBeanMethod.getLimit()
                && limitInfo.getDurationInSeconds() == registerBeanMethod.getDurationInSeconds();
    }
}
